#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, cnt[N], ans, a, b, res, t, can[N], lft;
priority_queue<int, vector<int>, greater<int>> pq;
queue<int> l;
int main(){
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &t);
        if(cnt[t] == 0){
            pq.push(t);
            lft++;
        }
        cnt[t]++;
        can[t]++;
    }
    while(lft > 1){
        a = pq.top();
        pq.pop();
        b = pq.top();
        pq.pop();
        while(can[b] == 0){
            l.push(b);
            b = pq.top();
            pq.pop();
        }
        // printf("cnt[%d]=%d, can=%d;\ncnt[%d]=%d, can=%d\n",
        // a, cnt[a], can[a], b, cnt[b], can[b]);
        if(cnt[a] > can[b]){
            cnt[a] -= can[b];
            can[b] = 0;
            pq.push(a);
            pq.push(b);
        }else{
            can[b] -= cnt[a];
            cnt[a] = 0;
            pq.push(b);
        }
        lft--;
        while(!l.empty()){
            pq.push(l.front());
            l.pop();
        }
    }
    while(!pq.empty()){
        ans += cnt[pq.top()];
        printf("%d cnt=%d can=%d\n", pq.top(), cnt[pq.top()], can[pq.top()]);
        pq.pop();
    }
    printf("%d\n", ans);
    return 0;
}